<?php
/**
 * Created by PhpStorm.
 * User: xujiang
 * Date: 2017/9/23
 * Time: 20:26
 */

function foobar($arg, $arg2) {
    return __FUNCTION__." got $arg and $arg2\n";
}

class foo {
    function bar($arg, $arg2) {
        echo __METHOD__, " got $arg and $arg2\n";
    }
}

call_user_func_array("foobar", array("one", "two"));

$foo = new foo;
call_user_func_array(array($foo, "bar"), array("three", "four"));

$func = function($arg1, $arg2) {
    return $arg1 * $arg2;
};

var_dump(call_user_func_array($func, array(2, 4))); /* As of PHP 5.3.0 */

function mega(&$a){
    $a = 55;
    echo "function mega \$a=$a\n";
}
$bar = 77;
call_user_func_array('mega',array(&$bar));
echo "global \$bar=$bar\n";
